import { Injectable, Inject } from '@angular/core';

import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';

import { User } from '../models/user';
// import { ServiceBuilder } from 'selenium-webdriver/edge';

@Injectable()
export class UserService {

  constructor(
    public http: HttpClient,
    @Inject('API_URL') private url: string

  ) { }


  // 更新密码
  changePassword(id: string, originalPassword: string, newPassword: string): Observable<Object> {
    //   const url = `${this.url1}security/user/password/${id}`;
    const url = `${this.url}security/user/password/${id}?oldPwd=${originalPassword}&newPwd=${newPassword}`;
      const headers = new HttpHeaders()
        .set('Content-Type', 'application/json;charset=UTF-8');
    // const params = new HttpParams()
    //   .set('oldPwd', originalPassword)
    //   .set('newPwd', newPassword)
    return this.http
      .put(url, { headers: headers});
  }
}
